/**
 *@description:
 *@file: game_object.h
 *@author: snow-tyan
 *@email: zziywang@163.com
 *@date: 1 February 2023
 *@copyright: 2018-2022 AiRiA. All rights reserved.
 */

#pragma once

#include <glad/glad.h>
#include <glm/glm.hpp>
#include <memory>

namespace mygl {

class Texture2D;
class SpriteRenderer;

namespace game {

class GameObject {
 public:
  // Constructor(s)
  GameObject();
  GameObject(glm::vec2 pos, glm::vec2 size, std::shared_ptr<Texture2D> sprite,
             glm::vec3 color = glm::vec3(1.0f), glm::vec2 velocity = glm::vec2(0.0f));
  // Draw sprite
  virtual void Draw(std::shared_ptr<SpriteRenderer> renderer);

  // Get Members
  bool is_solid() const { return is_solid_; }
  bool is_destroyed() const { return destroyed_; }
  glm::vec2 position() const { return position_; }
  glm::vec2 size() const { return size_; }
  glm::vec2 velocity() const { return velocity_; }

  // Set Members
  void set_solid(GLboolean is_solid) { is_solid_ = is_solid; }
  void set_destroyed(GLboolean destroyed) { destroyed_ = destroyed; }
  void set_position(glm::vec2 position) { position_ = position; }
  void set_size(glm::vec2 size) { size_ = size; }
  void set_velocity(glm::vec2 velocity) { velocity_ = velocity; }
  void set_rotation(GLfloat rotation) { rotation_ = rotation; }

 protected:
  // Object state
  glm::vec2 position_;
  glm::vec2 size_;
  glm::vec2 velocity_;
  glm::vec3 color_;
  GLfloat rotation_;
  GLboolean is_solid_;
  GLboolean destroyed_;
  // Render state
  std::shared_ptr<Texture2D> sprite_;
};

}  // namespace game
}  // namespace mygl
